
let path = require('path')  //node.js自带的模块
let HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
    devServer:{ //开发服务器配置
        port:7070,
        progress:true,//进度条
        contentBase:'src'
    },
    mode:'development',//模式，development开发模式,production生产模式
    entry:'./src/index.js',  //入口
    output:{
        filename:'bundle.js',  //打包后的文件名
        path:path.resolve(__dirname,'dist') //必须是绝对路径,所以需要借助path解析出绝对路径
    },
    plugins:[ //配置所有的webpack插件
        new HtmlWebpackPlugin({
            template:'./src/index.html',
            filename:'index.html'
        })
    ],
    module:{
        rules:[
            {test:/\.css$/,use:['style-loader','css-loader']}, //css加载器
            {test:/\.less$/,use:['style-loader','css-loader','less-loader']}, //less加载器
            {test:/\.scss$/,use:['style-loader','css-loader','less-loader']}, //sass加载器
            {test:/\.(jpg|jpeg|png|bmp|gif)$/,use:'url-loader'},
            {test:/\.js$/,use:'babel-loader',exclude:/node_modules/}
        ]
    }
}